//
//  FZ_BoFang_One_ViewController.m
//  ProjectOfBStage
//
//  Created by dllo on 15/11/13.
//  Copyright © 2015年 cuixin. All rights reserved.
//

#import "FZ_BoFang_One_ViewController.h"
#import "FZ_BoFang_Two_ViewController.h"
#import "FZ_BoFang_One_TableCell_One.h"
#import "FZ_BoFang_One_TableCell_Two.h"
#import "FZ_BoFang_One_TableCell_Three.h"
#import "FZ_BoFang_One_TableCell_Fourth.h"
#import "FZ_BoFang_One_TableCell_Two_ViewController.h"
#import "BaseHeader.h"
#import "FZ_RightCreatViewDongH.h"
#import "ChannerModel.h"
#import "CustomerNetworking.h"
#import "CXFirstDetailModel.h"
#import "CXDetailFirstViewController.h"
#import "FZ_RightCreatViewDongH.h"
static BOOL boFangStateSSs = YES;
@interface FZ_BoFang_One_ViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic ,retain) UITableView *tableViewOne;
@property (nonatomic, retain) UITapGestureRecognizer *tapTouXiang;
@property(nonatomic, copy)NSString *detailID;
@property(nonatomic, assign)BOOL boFangStateSS;
@property (nonatomic ,retain) FZ_RightCreatViewDongH *CreatViewOS;
@end

@implementation FZ_BoFang_One_ViewController

- (void)dealloc {
    [_Imodel release];
    [_tapTouXiang release];
    [_tableViewOne release];
    [super dealloc];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self createTableView];
    [self creatItem];
    [self creatTransLayer];
   
}

- (void)creatTransLayer{
    self.CreatViewOS = [[FZ_RightCreatViewDongH alloc] initWithFrame:CGRectMake(0, 0, 36.f, 36.f)];
    self.tapTouXiang = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapTouXiangFirstVC:)];
    [self.CreatViewOS addGestureRecognizer:self.tapTouXiang];
    [_tapTouXiang release];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:self.CreatViewOS];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveNotificationKF:) name:YINYUE_STATE_K object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveNotificationTS:) name:YINYUE_STATE_T object:nil];
}
- (void)receiveNotificationKF:(NSNotification *)notification{
    self.boFangStateSS = YES;
}
- (void)receiveNotificationTS:(NSNotification *)notification{
    self.boFangStateSS = NO;
}

- (void)creatItem{
    
    UIImage *imageLeft = BACK_ITEM_BAR;
    imageLeft = [imageLeft imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:imageLeft style:UIBarButtonItemStylePlain target:self action:@selector(leftBarAction:)];
}

- (void)createTableView{
    self.tableViewOne = [[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStylePlain];
    self.tableViewOne.delegate = self;
    self.tableViewOne.bounces = NO;
    self.tableViewOne.dataSource = self;
    [self.view addSubview:self.tableViewOne];
    [_tableViewOne release];
    
    
    UINib *nibTwo = [UINib nibWithNibName:@"FZ_BoFang_One_TableCell_Two" bundle:[NSBundle mainBundle]];
    UINib *nibThree = [UINib nibWithNibName:@"FZ_BoFang_One_TableCell_Three" bundle:[NSBundle mainBundle]];
    UINib *nibFourth = [UINib nibWithNibName:@"FZ_BoFang_One_TableCell_Fourth" bundle:[NSBundle mainBundle]];
    [self.tableViewOne registerClass:[FZ_BoFang_One_TableCell_One class] forCellReuseIdentifier:@"FZ_BoFang_One_TableCell_One"];
    [self.tableViewOne registerNib:nibTwo forCellReuseIdentifier:@"FZ_BoFang_One_TableCell_Two"];
    [self.tableViewOne registerNib:nibThree forCellReuseIdentifier:@"FZ_BoFang_One_TableCell_Three"];
    [self.tableViewOne registerNib:nibFourth forCellReuseIdentifier:@"FZ_BoFang_One_TableCell_Fourth"];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
        return 3;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 1.f;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0) {
        FZ_BoFang_One_TableCell_One *cell1 = [tableView dequeueReusableCellWithIdentifier:@"FZ_BoFang_One_TableCell_One"];
        cell1.modelJieShouT = self.Imodel;
//        cell1.backgroundColor = [UIColor yellowColor];
        cell1.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell1;
    }
    if (indexPath.row == 1) {
        FZ_BoFang_One_TableCell_Two *cell2 = [tableView dequeueReusableCellWithIdentifier:@"FZ_BoFang_One_TableCell_Two"];
        cell2.modelJieShouL = self.Imodel;
//        cell2.backgroundColor = [UIColor orangeColor];
        cell2.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell2;
    }
    else {
        FZ_BoFang_One_TableCell_Three *cell3 = [tableView dequeueReusableCellWithIdentifier:@"FZ_BoFang_One_TableCell_Three"];
        
        cell3.modelJieShouP = self.Imodel;

//        cell3.backgroundColor = [UIColor yellowColor];
        cell3.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell3;
    }
    
//    {
//        FZ_BoFang_One_TableCell_Fourth *cell4 = [tableView dequeueReusableCellWithIdentifier:@"FZ_BoFang_One_TableCell_Fourth"];
//        cell4.modelJieShouG = self.Imodel;
//        return cell4;
//    }
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0) {
        return 340.f;
    }
    if (indexPath.row == 1) {
        return 55.f;
    }
    if (indexPath.row == 2) {
        return 120.f;
    }
    else{
        return 260.f;
    }
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0) {
    }
    if (indexPath.row == 1) {
    }
    if (indexPath.row == 2) {
        CXDetailFirstViewController *DetailFirstViewController = [[CXDetailFirstViewController alloc] init];
        DetailFirstViewController.detailID = self.PicID;
        DetailFirstViewController.bigImage = self.Imodel.pic;
        [self.navigationController pushViewController:DetailFirstViewController animated:YES];
        [DetailFirstViewController release];
    }
    else{
    }
}
- (void)viewWillAppear:(BOOL)animated{
    self.boFangStateSS = boFangStateSSs;
    if (self.boFangStateSS) {
        self.CreatViewOS = [[FZ_RightCreatViewDongH alloc] initWithFrame:CGRectMake(0, 0, 36.f, 36.f)];
        self.tapTouXiang = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapTouXiangFirstVC:)];
        [self.CreatViewOS addGestureRecognizer:self.tapTouXiang];
        [_tapTouXiang release];
        self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:self.CreatViewOS];
    }else{
        [self.CreatViewOS removeAnimat];
    }
    self.tabBarController.tabBar.hidden = NO;
    self.navigationController.navigationBar.hidden = NO;
    
}
- (void)tapTouXiangFirstVC:(UIBarButtonItem *)sender{
    FZ_BoFang_Two_ViewController *boFangTwo = [FZ_BoFang_Two_ViewController sharePlayer];
    boFangTwo.JieShouModel = self.Imodel;
    boFangTwo.indexRow = self.indexRowF;
    boFangTwo.pic = self.Imodel.pic;
    boFangTwo.allMusicArray = self.arrayF;
    boFangTwo.name = self.Imodel.name;
    boFangTwo.playUrl = self.Imodel.source;
    [self.navigationController pushViewController:boFangTwo animated:YES];
    self.navigationController.navigationBar.hidden = YES;
}
- (void)leftBarAction:(UIBarButtonItem *)sender{
    [self.navigationController popViewControllerAnimated:YES];
}


@end
